/*
 * Copyright (c) 2013 WDCY Information Technology Co. Ltd
 * www.wdcy.cc
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * WDCY Information Technology Co. Ltd ("Confidential Information").
 * You shall not disclose such Confidential Information and shall use
 * it only in accordance with the terms of the license agreement you
 * entered into with WDCY Information Technology Co. Ltd.
 */
package com.monkey.web.dto.response.role;


import com.monkey.core.domain.role.Role;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Wu Tianqiang
 */
public class RoleJSONDto {

    private Long roleId;
    private String name;
    private String role;
    private List<ResourcePermissionJSONDto> resourcePermissions = new ArrayList<>();

    public RoleJSONDto(Role role) {
        this.roleId = role.getId();
        this.name = role.getName();
        this.role = role.getRole();
//        this.resourcePermissions = ResourcePermissionJSONDto.toJSONDto(role.getRoleResourcePermissions());
    }

    public static List<RoleJSONDto> toJSONDto(List<Role> roles) {
        List<RoleJSONDto> roleJSONDtos = new ArrayList<>();
        for (Role role : roles) {
            roleJSONDtos.add(new RoleJSONDto(role));
        }
        return roleJSONDtos;
    }

    public Long getRoleId() {
        return roleId;
    }

    public void setRoleId(Long roleId) {
        this.roleId = roleId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getRole() {
        return role;
    }

    public void setRole(String role) {
        this.role = role;
    }

    public List<ResourcePermissionJSONDto> getResourcePermissions() {
        return resourcePermissions;
    }

    public void setResourcePermissions(List<ResourcePermissionJSONDto> resourcePermissions) {
        this.resourcePermissions = resourcePermissions;
    }
}